<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of SignInLinkGen
 *
 * @author aneto
 */
class SignInLinkGen extends LinkGen{
	
	public function link($id, $additionalParams = array()){
		if(!isset($id))
			$id = $this->getAction()->getRoute()->getObject()->getId();

		$structNode = LinkGen::getInstance(LinkGen::STRUCTURE)->linkParts(
			$id
		);

		return url_for('structure_actions', array_merge(
				array('p0' => $structNode['p0']),
				array('action' => 'signIn', 'module' => 'publicUserRegistration'),
				$additionalParams
		));

	}

	public function specialLink($param, $additionalParams = array()){
		$result = '';
		switch($param){
			case 'memberzone':
				$result = LinkGen::getInstance(LinkGen::STRUCTURE)->link(
					Doctrine::getTable('Structure')->findOneByParameterAndLang('memberzone', $this->getAction()->getRoute()->getObject()->getLang())->getId());
				break;
			case 'login':
				$node = Doctrine::getTable('Structure')->findOneByParameterAndLang('login', $this->getAction()->getRoute()->getObject()->getLang());
				if($node)
					$result = LinkGen::getInstance(LinkGen::STRUCTURE)->link($node->getId());
				else
					$result = "#";
				break;
			case 'passwordReminder':
				$node = Doctrine::getTable('Structure')->findOneByParameterAndLang('password_reminder', $this->getAction()->getRoute()->getObject()->getLang());
				if($node)
					$result = LinkGen::getInstance(LinkGen::STRUCTURE)->link($node->getId());
				else
					$result = "#";
				break;
			default:
				break;
		}

		return $result;
	}

	protected function init(){

	}

	public function linkParts($id, $additionalParams = array()){

	}
}
?>
